package views
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.BevelFilter;
	import flash.geom.Point;
	
	import mx.core.UIComponent;
	
	import util.Rotator;
	
	public class NabEarView extends UIComponent
	{
		private var ear: Sprite;
		private var angle: int = 0;
		private var rotator: Rotator;
		
		public function NabEarView()
		{
			super();
		}
		
		override protected function createChildren(): void {
			super.createChildren();
			ear = new Sprite();
			ear.filters = [
				new BevelFilter(10, 45, 0xffffff, .7, 0xA09E97, .7, 13, 13, 1, 3)
			];
			rotator = new Rotator(ear, new Point(10, 70));
			drawEar();
			addEventListener(Event.ENTER_FRAME, rotate);
		}
		
		private function drawEar(): void {
			var g: Graphics = ear.graphics;
			var x: int = 0;
			var y: int = 0;
			g.beginFill(0xFFFFFF);
			g.lineStyle(1, 0xD3D3D3,0.8);
			g.moveTo(x, y);
			g.curveTo(x, y-20, x+10, y-20);
			g.curveTo(x+20, y-20, x+20, y);
			g.lineTo(x+20, y+70);
			g.curveTo(x+20, y+90, x+10, y+90);
			g.curveTo(x, y+90, x, y+70);
			g.endFill();
			addChild(ear);
		}
		
		private function rotate(event: Event): void {
			rotator.rotation += 5;
		}
		
	}
}